package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

/**
 * 账号手机号码验证请求参数类
 *
 * @author lijian
 * @version 2014年3月26日 - 下午7:31:41
 */
public class UserVerifyPhoneRequest extends Request {
	
	/**
	 * 手机号码
	 */
	private String phone;

	/** */
	public UserVerifyPhoneRequest() {
	}
	
	@Override
	public void parse(HttpServletRequest request) {
		
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.phone = requestInfo.getParameter(ApiUrlParamEnum.phone.getParamName(), "");
		if (StringUtil.isEmpty(phone)) {
			throw new RequestIllegalException("手机号码不能为空");
		}
		if (!StringUtil.isEmpty(phone) && !StringUtil.isMobilePhone(phone)) {
			throw new RequestIllegalException("手机号码格式有误");
		}
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}
	
}
